package com.neuedu.his.dao;

import com.neuedu.his.entity.ConstantType;
import com.neuedu.his.entity.ConstantType;
import com.neuedu.his.framework.BaseDao;
import com.neuedu.util.JDBCUtil;

import java.util.List;

/**
 * 项目：      his
 * 类名:       ConstantTypeDao
 * 创建时间：  2020/12/23  8:43
 * 描述 :     用户数据访问层
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class ConstantTypeDao implements BaseDao<ConstantType> {


    public  List<ConstantType> selectList(String sql, Object... args) {
        return JDBCUtil.executeQuery(sql, ConstantType.class, args);
    }

    @Override
    public ConstantType selectById(Integer id) {
        String sql = " select * from constant_type where id = ?";
        return JDBCUtil.getOne(sql, ConstantType.class, id);
    }

    @Override
    public boolean update(ConstantType constantType) {

       String sql  = " UPDATE  constant_type SET  CODE = ?,  NAME = ? WHERE id = ? ";

        return JDBCUtil.executeUpdate(sql,
                constantType.getCode(),
                constantType.getName(),
                constantType.getId()
        );
    }


    /**
     * 逻辑删除，没有真正删除数据
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Integer id) {

        String sql = " update  constant_type set active = 0 where id  = ? ";

        return JDBCUtil.executeUpdate(sql,id);
    }

    @Override
    public boolean batchDel(String sql, Object... parm) {
        return false;
    }

    @Override
    public boolean insert(ConstantType constantType) {
        String sql = " INSERT INTO constant_type(   code,name )  VALUES ( ? , ?)  ";
        return JDBCUtil.executeUpdate(sql, constantType.getCode(),constantType.getName());
    }


}
